package io.github.eiot.charge.ykc.data;

import io.github.eiot.annotation.Frame;
import io.github.eiot.annotation.FrameField;
import io.github.eiot.codec.BCD;

/**
 * 充电结束请求 0x21
 *
 * @author yan
 * @since 2025-09-06
 */
@Frame
public class YkcBmsChargeStop implements YkcHasTerminalNo, YkcHasGunNo {

    /**
     * 交易流水号 BCD码 16
     */
    @FrameField(len = 16)
    private BCD orderNo;

    /**
     * 桩编号 BCD码 7
     */
    @FrameField(len = 7)
    private BCD terminalNo;

    /**
     * 枪号 BIN码 1
     */
    @FrameField(len = 1)
    private int gunNo;

    /**
     * 充电机中止充电原因 BIN码 1
     * 1-2 位——达到充电机设定的条件中止
     * 3-4 位——人工中止
     * 5-6 位——异常中止
     * 7-8 位——BMS 主动中止
     */
    @FrameField(len = 1)
    private int chargeStopReason;

    /**
     * 充电机中止充电故障原因 BIN码 2
     * 1-2 位——充电机过温故障
     * 3-4 位——充电连接器故障
     * 5-6 位——充电机内部过温
     * 故障 7-8 位——所需电量不
     * 能传送
     * 9-10 位——充电机急停故障
     * 11-12 位——其他故障
     * 13-16 位——预留位
     */
    @FrameField(len = 2)
    public int chargeStopFaultReason;

    /**
     * 充电机中止充电错误原因 BIN码 1
     * 1-2 位——电流不匹配
     * 3-4 位——电压异常
     * 5-8 位——预留位
     */
    @FrameField(len = 1)
    public int chargeStopErrorReason;

    /**
     * getter auto generated
     */
    public BCD getOrderNo() {
        return orderNo;
    }

    /**
     * setter auto generated
     */
    public void setOrderNo(BCD orderNo) {
        this.orderNo = orderNo;
    }

    /**
     * setter auto generated
     */
    public void setOrderNo(String orderNo) {
        io.github.eiot.utils.ValidationUtil.lteLen(orderNo, 32, orderNo);
        this.orderNo = BCD.from(orderNo, 32);
    }

    /**
     * getter auto generated
     */
    public BCD getTerminalNo() {
        return terminalNo;
    }

    /**
     * setter auto generated
     */
    public void setTerminalNo(BCD terminalNo) {
        this.terminalNo = terminalNo;
    }

    /**
     * setter auto generated
     */
    public void setTerminalNo(String terminalNo) {
        io.github.eiot.utils.ValidationUtil.lteLen(terminalNo, 14, terminalNo);
        this.terminalNo = BCD.from(terminalNo, 14);
    }

    /**
     * getter auto generated
     */
    public int getGunNo() {
        return gunNo;
    }

    /**
     * setter auto generated
     */
    public void setGunNo(int gunNo) {
        this.gunNo = gunNo;
    }

    /**
     * getter auto generated
     */
    public int getChargeStopReason() {
        return chargeStopReason;
    }

    /**
     * setter auto generated
     */
    public void setChargeStopReason(int chargeStopReason) {
        this.chargeStopReason = chargeStopReason;
    }

    /**
     * getter auto generated
     */
    public int getChargeStopFaultReason() {
        return chargeStopFaultReason;
    }

    /**
     * setter auto generated
     */
    public void setChargeStopFaultReason(int chargeStopFaultReason) {
        this.chargeStopFaultReason = chargeStopFaultReason;
    }

    /**
     * getter auto generated
     */
    public int getChargeStopErrorReason() {
        return chargeStopErrorReason;
    }

    /**
     * setter auto generated
     */
    public void setChargeStopErrorReason(int chargeStopErrorReason) {
        this.chargeStopErrorReason = chargeStopErrorReason;
    }
}
